package com.example.lab.controller;

import com.example.lab.entity.Device;
import com.example.lab.entity.Room;
import com.example.lab.service.SelectService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/query")
public class SelectController {
    @Resource
    SelectService selectService;

    @ResponseBody
    @RequestMapping("/queryR")
    public List<Room> query() {
        List<Room> query = selectService.query();
        return query;
    }

    @ResponseBody
    @RequestMapping("/queryD")
    public List<Device> queryDevice(@RequestParam String id) {
        List<Device> queryRoom = selectService.queryById(id);
        return queryRoom;
    }
}
